#include "cmd_var.h"
#include "mem_manager.h"

#include "core_searchTree.h"


#include <string.h>


static CSearchTree *searchTree;


void cmd_initVar()
{
	g_alloc(searchTree, CSearchTree());
}

void cmd_shutdownVar()
{
	g_free(searchTree);
}

void cmd_setVar(const char* name, float val)
{
	float *v;
	g_alloc(v, float);
	*v = val;
	searchTree->addNode(name, v);
}

float cmd_getVar(const char* name)
{
	float *v = (float*)searchTree->getNode(name);

	if (v)
		return *v;

	return 0.0f;
}

bool cmd_isVar(const char* name)
{
	return (searchTree->getNode(name) != NULL);
}